import { IHotSong } from "./hotsongs.action";

export const GET_SONG_DETAIL = "GET_SONG_DETAIL";
export const GET_SONG_DETAIL_SUCCESS = "GET_SONG_DETAIL_SUCCESS";
export const GET_SONG_DETAIL_FAILED = "GET_SONG_DETAIL_FAILED";

export interface IGetSongDetailAction {
  type: typeof GET_SONG_DETAIL;
  payload: string;
}

export interface ISongDetailResult {
  code: number;
  songs: IHotSong[];
  privileges: any[];
}

export interface IGetSongDetailSuccessAction {
  type: typeof GET_SONG_DETAIL_SUCCESS;
  payload: ISongDetailResult;
}

export interface IGetSongDetailFailedAction {
  type: typeof GET_SONG_DETAIL_FAILED;
  payload: string;
}

export const getSongDetail = (songId: string): IGetSongDetailAction => {
  return {
    type: GET_SONG_DETAIL,
    payload: songId,
  };
};

export const getSongDetailSuccess = (
  payload: ISongDetailResult
): IGetSongDetailSuccessAction => {
  return {
    type: GET_SONG_DETAIL_SUCCESS,
    payload,
  };
};

export const getSongDetailFailed = (
  payload: string
): IGetSongDetailFailedAction => {
  return {
    type: GET_SONG_DETAIL_FAILED,
    payload,
  };
};

export type GetSongdetailUnionType =
  | IGetSongDetailSuccessAction
  | IGetSongDetailFailedAction
  | IGetSongDetailAction;
